package com.giacom.xml.util;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

/**
 * Classe utilitaria para tratamento de XML
 * @author sandro.giacomozzi
 *
 */
public class JaxbUtil {
	
	
	/**
	 * Converte um object Jaxb em arquivo XML
	 * @param fileName
	 * @param jaxbElement
	 * @throws Exception
	 */
	public static void generateXML(String fileName, Object jaxbElement) throws Exception{
		JAXBContext context = JAXBContext.newInstance("com.giacom.document");
		Marshaller marshaller = context.createMarshaller();
		
		File f = new File(fileName);
		marshaller.marshal(jaxbElement, f);
		
		System.out.println("Arquivo gerado: " + f.getAbsoluteFile());
		
	}

}
